package ar.com.personalTravellers.beans;

import com.angel.arquitectura.model.common.PersistentObject;

import javax.persistence.CascadeType;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import java.util.ArrayList;
import java.util.List;

@MappedSuperclass
public abstract class Provider extends PersistentObject{

    @OneToOne(cascade = CascadeType.ALL, optional = false)
    private Address address;

    @OneToMany(cascade = CascadeType.ALL)
    private List<Contact> contacts;

    private String urlAddress;

    private String email;

    private String name;

    private String telephone;

    public Provider() {
        super();
        this.contacts = new ArrayList<Contact>();
    }

    public Provider(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrlAddress() {
        return urlAddress;
    }

    public void setUrlAddress(String urlAddress) {
        this.urlAddress = urlAddress;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public List<Contact> getContacts() {
        return contacts;
    }

    public void setContacts(List<Contact> contacts) {
        this.contacts = contacts;
    }

    public boolean addContact(Contact contact) {
        return this.contacts.add(contact);
    }


    public boolean removeContact(Contact contact) {
        return this.contacts.remove(contact);
    }
}